<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('列表')" />
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">

        <input id="templateId" name="templateId" th:value="${templateId}"  type="hidden">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="performance:perTemplateSpec:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="performance:perTemplateSpec:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="performance:perTemplateSpec:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="performance:perTemplateSpec:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('performance:perTemplateSpec:edit')}]];
    var removeFlag = [[${@permission.hasPermi('performance:perTemplateSpec:remove')}]];
    var prefix = ctx + "performance/perTemplateSpecRelation";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add?templateId="+$('#templateId').val(),
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "",
            showExport: true,
            queryParams:queryParams,
            columns: [{
                checkbox: true
            },
                {
                    field : 'relationId',
                    title : '',
                    visible: false
                },
                {
                    field : 'specName',
                    title : '考核项名称',
                    sortable: false
                },{
                    field : 'specContent',
                    title : '考核项内容',
                    sortable: false
                },
                {
                    field : 'weightPer',
                    title : '权重',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.relationId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.relationId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        var search = $.table.queryParams(params);
        search.templateId = $("#templateId").val();
        return search;
    }

</script>
</body>
</html>